package com.grep.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.grep.extra.dao.impl.TaskDAOSQL;

/**
 * Servlet implementation class NewTaskUrl
 */
public class NewTaskUrl extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		
		TaskDAOSQL taskDaoSql = new TaskDAOSQL();
		
		String taskName = request.getParameter("taskname");
		String urlLink = request.getParameter("urllink");
		String taskId = taskDaoSql.getIdByTaskName(taskName); 
		
		boolean issuccess =  taskDaoSql.insertTaskURL(taskId, urlLink);
		
		String url = "common/success.jsp?issuccess="+issuccess;
		response.sendRedirect(url);
	
	}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}	
}
